home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / BatchJavaDoc.java < prev    next >
Text File  |  1998-09-08  |  3KB  |  96 lines

  1. package com.symantec.itools.tools.utilities;
  2.  
  3.  
  4. import java.io.FileNotFoundException;
  5. import java.io.FileWriter;
  6. import java.io.IOException;
  7. import java.io.PrintWriter;
  8. import com.symantec.itools.io.Directory;
  9. import com.symantec.itools.io.FileSystem;
  10. import com.symantec.itools.io.NotDirectoryException;
  11. import com.symantec.itools.io.WildCardFileFilenameFilter;
  12.  
  13.  
  14. /**
  15.  * @author Symantec Internet Tools Division
  16.  * @version 1.0
  17.  * @since VCafe 3.0
  18.  */
  19.  
  20. public class BatchJavaDoc
  21. {
  22.     /**
  23.      * @param argv TODO
  24.      * @since VCafe 3.0
  25.      */
  26.     public static void main(String[] argv)
  27.     {
  28.         String       baseDir;
  29.         int          index;
  30.         String[]     dirs;
  31.         StringBuffer list;
  32.         
  33.         baseDir = FileSystem.getCanonicalPath(argv[0], true);
  34.         index   = baseDir.length();
  35.         list    = new StringBuffer();
  36.         
  37.         try
  38.         {
  39.             dirs = new Directory(argv[0]).listDirectories(true);
  40.         
  41.             for(int i = 0; i < dirs.length; i++)
  42.             {
  43.                 String pkg;
  44.             
  45.                 pkg = dirs[i].substring(index).replace('\\', '.');
  46.             
  47.                 if((pkg != null) && !(pkg.equals("")))
  48.                 {
  49.                     Directory currentDir;
  50.                     
  51.                     currentDir = new Directory(dirs[i]);
  52.                     
  53.                     // any .java files in this dir?
  54.                     if(currentDir.listFiles(
  55.                         new WildCardFileFilenameFilter("*.java", false), false).length > 0)
  56.                     {
  57.                         list.append(pkg);
  58.                         list.append(' ');           
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.         catch(NotDirectoryException ex)
  64.         {
  65.             System.err.println(argv[0] + " is not a directory");
  66.             System.exit(1);
  67.         }
  68.         catch(FileNotFoundException ex)
  69.         {
  70.             System.err.println(argv[0] + " does not exist");
  71.             System.exit(2);
  72.         }
  73.         catch(IOException ex)
  74.         {
  75.             System.err.println("Error processing " + argv[0]);
  76.             System.exit(3);
  77.         }
  78.  
  79.         try
  80.         {
  81.             FileWriter  writer;
  82.             PrintWriter printer;
  83.             
  84.             writer  = new FileWriter(argv[1]);
  85.             printer = new PrintWriter(writer);
  86.             printer.println(list);
  87.             printer.flush();
  88.             printer.close();
  89.         }
  90.         catch(IOException ex)
  91.         {
  92.             System.err.println("Error writing " + argv[1]);
  93.             System.exit(4);
  94.         }
  95.     }
  96. }